﻿@using LdCms.EF.DbModels
@model Ld_Log_Table
@{
    ViewData["Title"] = "Edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<article class="page-container">
    <form action="@Url.Action("Update",new { TableID = Model.TableID })" method="post" class="form form-horizontal" id="form-add">
        <div class="row cl">
            <div class="admin-add-top-tips">提示：员工初始化密码为手机后8位组成。</div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>数据表名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.TableName" placeholder="" id="fTableName" name="fTableName" disabled />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>业务注释：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.BusinessName" placeholder="数据表中文注释" id="fBusinessName" name="fBusinessName" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea id="fRemark" name="fRemark" class="textarea" placeholder="写点什么...100个字符以内" dragonfly="true">@Model.Remark</textarea>
                <p class="textarea-numberbar"></p>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@*
    --------------
    页面底部JS脚本
    --------------
*@
@section scripts{
    <!--请在下方写此页面业务相关的脚本-->
    <script type="text/javascript" src="~/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="~/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="~/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
        (function ($) {
            $.mainu = {
                init: function () {
                    $('.skin-minimal input').iCheck({
                        checkboxClass: 'icheckbox-blue',
                        radioClass: 'iradio-blue',
                        increaseArea: '20%'
                    });
                    $("#fRemark").Huitextarealength({
                        minlength: 4,
                        maxlength: 200
                    });
                },
                formSubmit: function () {
                    $("#form-add").validate({
                        rules: {
                            fTableText: {
                                required: true
                            }
                        },
                        onkeyup: false,
                        focusCleanup: true,
                        success: "valid",
                        submitHandler: function (form) {
                            $(form).ajaxSubmit({
                                type: "POST",
                                cache: false,
                                dataType: "json",
                                error: function (XMLHttpRequest, textStatus, errorThrown) {
                                    if (XMLHttpRequest.status != 200) {
                                        layer.alert("POST[FAIL]", { icon: 5 });
                                    }
                                },
                                success: function (result) {
                                    var state = result.state;          //错误代码
                                    var message = result.message;        //错误说明
                                    if (state == "success") {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.location.reload();
                                        parent.layer.close(index);
                                    } else {
                                        layer.alert(message, { icon: 5 });
                                    }
                                }
                            });
                        }
                    });
                }
            };
            $(function () {
                $.mainu.init();
                $.mainu.formSubmit();
            });

        })(jQuery);
    </script>
}

